{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "bc604416-27c4-4b19-afa3-91a16b16726e",
   "metadata": {},
   "source": [
    "https://leetcode.com/problems/rotate-list\n",
    "\n",
    "\n",
    "Runtime: 4 ms, faster than 26.16% of Go online submissions for Rotate List.\n",
    "Memory Usage: 4.4 MB, less than 8.86% of Go online submissions for Rotate List.\n",
    "\n",
    "\n",
    "```go\n",
    "func rotateRight(head *ListNode, k int) *ListNode {\n",
    "\t//8:55\n",
    "\tl := make([]*ListNode, 0)\n",
    "\tnode := head\n",
    "\tfor node != nil {\n",
    "\t\tl = append(l, node)\n",
    "\t\tnode = node.Next\n",
    "\t}\n",
    "\n",
    "\tif len(l) == 0 {\n",
    "\t\treturn nil\n",
    "\t}\n",
    "\n",
    "\tk = k % len(l)\n",
    "\ti := 0\n",
    "\tfor i < k {\n",
    "\t\tindex := len(l) - 1\n",
    "        temp_l := l[index:]\n",
    "\t\ttemp_l = append(temp_l, l[:index]...)\n",
    "        l = temp_l\n",
    "\t\ti += 1\n",
    "\t}\n",
    "\n",
    "\tfor i, node := range l {\n",
    "\t\tif i < len(l)-1 {\n",
    "\t\t\tnode.Next = l[i+1]\n",
    "\t\t} else {\n",
    "\t\t\tnode.Next = nil\n",
    "\t\t}\n",
    "\t}\n",
    "\n",
    "\treturn l[0]\n",
    "\t//9:00\n",
    "}\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "0d7d769b-19b6-4a50-bbd7-3847d4143bda",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Go",
   "language": "go",
   "name": "gophernotes"
  },
  "language_info": {
   "codemirror_mode": "",
   "file_extension": ".go",
   "mimetype": "",
   "name": "go",
   "nbconvert_exporter": "",
   "pygments_lexer": "",
   "version": "go1.14.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
